package com.pioneer.web.archive.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pioneer.web.archive.domain.ArcStore;
import com.pioneer.web.archive.mapper.ArcStoreMapper;
import com.pioneer.web.archive.service.IArcStoreService;
import org.springframework.stereotype.Service;

/**
 * ArcStoreServiceImpl
 *
 * @author hlm
 * @date 2025-03-19 15:46:34
 */
@Service
public class ArcStoreServiceImpl extends ServiceImpl<ArcStoreMapper, ArcStore> implements IArcStoreService {

    @Override
    public boolean checkCodeUnique(ArcStore store) {
        LambdaQueryWrapper<ArcStore> query = Wrappers.lambdaQuery();
        query.eq(ArcStore::getStoreCode, store.getStoreCode());
        if (store.getStoreId() != null) {
            query.ne(ArcStore::getStoreId, store.getStoreId());
        }
        return getBaseMapper().exists(query);
    }
}
